package com.itheima.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;

public class Test005 {
    public static void main(String[] args) {
        /*
        3.1 ArrayList有以下元素: "a","f","b","c","a","d"，
        请用任意方式完成集合元素去重。去除集合中重复的元素。
         */
        ArrayList<String > list = new ArrayList<>();
        Collections.addAll(list,"a","f","b","c","a","d");
        //创建一个set集合;
        HashSet<String> set = new HashSet<>();
        //将list里面的元素添加到set当中;
        for (String s : list) {
            set.add(s);
        }
        //清楚list里面的元素;
        list.clear();
        //将set里面的元素添加到list当中;
        for (String s : set) {
            list.add(s);
        }
        System.out.println(list);
    }
}
